package com.headwire.kw.helpers;

import java.util.List;

public class StringUtil
{
	public static String join(List<String> list, char delim) {
		return join(list,""+delim);
	}
	
	public static String join(List<String> list, String delim) {
		StringBuilder sb = new StringBuilder();
		boolean firstRun = true;
		for(String s : list) {
			if(firstRun) {
				firstRun = false;
			}
			else {
				sb.append(delim);
			}
			sb.append(s);
		}
		return sb.toString();
	}
	
	public static String join(String[] list, char delim) {
		return join(list,""+delim);
	}
	
	public static String join(String[] list, String delim) {
		StringBuilder sb = new StringBuilder();
		for(int i =0; i < list.length; i++) {
			if(i > 0) sb.append(delim);
			sb.append(list[i]);
		}
		return sb.toString();
	}
}
